<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page  import="com.apache.workday.*"%>
<%@page  import="java.util.*"%>
<%@page import="net.sf.json.*"%>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<%@ include file="/common/plateform/include/common-base.jsp"%>
	<script type="text/javascript" src="${ctx}/common/plateform/base/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src='${ctx}/common/plateform/base/workday/workday.js'></script>
	<link rel="stylesheet" type="text/css" href="${ctx}/common/plateform/base/workday/workday.css">
	<title>工作日管理</title>
</head>
<body>
<%
	String year = request.getParameter("year");
	if(year==null){
		year = new String(String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
	}

	java.util.List<Workday> list =  WorkdayUtils.getInstance().getDayListOfYear(year);
	String jsonStr = JSONArray.fromObject(list).toString();
%>
<script>
    var clickMenu = "workday";
    //初始化日期
    function initCal(year){
        document.write("<table>");
        for(var i=1;i<=12;i++){
            if ((i - 1) % 4 == 0){document.write("<tr>");}
            document.write("<td>");
            workDay(year , i);
            document.write("</td>");
            if (i % 4 == 0){document.write("</tr>");}
        }
        document.write("</table>");
    }
    //暂时没用
    function initCalNew(year){
        $.post(common_submit_url+"/workday",{"year":year},
            function(data){
                // console.log(data);
                if(data.flag=="T"){
                    /**
                     var jsonAry = jQuery.parseJSON(data.msg);
                     var htmlDataTable = "";
                     htmlDataTable+="<table>";
                     for(var i=1;i<=12;i++){
							if ((i - 1) % 4 == 0){
							    htmlDataTable+="<tr>";
							}
                            htmlDataTable+="<td>";
							workDay(year , i);//此处还需要改？？？？
                            htmlDataTable+="</td>";
							if (i % 4 == 0){
							    htmlDataTable+="</tr>";
							}
						}
                     htmlDataTable+="<table>";
                     alert(htmlDataTable);
                     $("#body-data-table").html(htmlDataTable);
                     alert($("#body-data-table").html());
                     **/
                }
            });
    }
    /**点击日期，进行提交设置*/
    function clickDateNode(node){
        var setWorkday = "F";//默认设置休息日
        if(node.className.indexOf('calendar-selected')>-1){
            setWorkday = "T";//如果已经是休息日，则说明是要设置为工作日
        }
        $.post(common_submit_url+"/workday", {act:"set", day: node.id, isWorkday: setWorkday },
            function(data){
                if(setWorkday == "F"){
                    node.className +=' calendar-selected ';
                }else{
                    node.className = node.className.replace('calendar-selected','');
                }
            });
    }

    //根据已经设置的工作日进行反显
    function displayCss(jsonAry){
        for(var i=0;i<jsonAry.length;i++){
            var jsonDay = jsonAry[i];
            //alert(jsonDay.isWorkday);
            setDayCss(jsonDay.dateStr,jsonDay.isWorkday);
        }
    }
</script>
<script type="text/javascript">
    initCal('<%=year%>');
    var jsonAry = jQuery.parseJSON('<%=jsonStr%>');
    displayCss(jsonAry);
    /**
     $(function(){
											initCalNew('<%=year%>');
										});**/
</script>
</body>
</html>


